package com.ruoyi.school.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.school.domain.JobImage;
import com.ruoyi.school.service.IJobImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 就业服务图片Controller
 * 
 * @author ruoyi
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/school/jobImage")
public class JobImageController extends BaseController
{
    @Autowired
    private IJobImageService jobImageService;

    /**
     * 查询就业服务图片列表
     */
    @PreAuthorize("@ss.hasPermi('school:jobImage:list')")
    @GetMapping("/list")
    public TableDataInfo list(JobImage jobImage)
    {
        startPage();
        List<JobImage> list = jobImageService.selectJobImageList(jobImage);
        return getDataTable(list);
    }

    /**
     * 导出就业服务图片列表
     */
    @PreAuthorize("@ss.hasPermi('school:jobImage:export')")
    @Log(title = "就业服务图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JobImage jobImage)
    {
        List<JobImage> list = jobImageService.selectJobImageList(jobImage);
        ExcelUtil<JobImage> util = new ExcelUtil<JobImage>(JobImage.class);
        util.exportExcel(response, list, "就业服务图片数据");
    }

    /**
     * 获取就业服务图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('school:jobImage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jobImageService.selectJobImageById(id));
    }

    /**
     * 新增就业服务图片
     */
    @PreAuthorize("@ss.hasPermi('school:jobImage:add')")
    @Log(title = "就业服务图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobImage jobImage)
    {
        return toAjax(jobImageService.insertJobImage(jobImage));
    }

    /**
     * 修改就业服务图片
     */
    @PreAuthorize("@ss.hasPermi('school:jobImage:edit')")
    @Log(title = "就业服务图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobImage jobImage)
    {
        return toAjax(jobImageService.updateJobImage(jobImage));
    }

    /**
     * 删除就业服务图片
     */
    @PreAuthorize("@ss.hasPermi('school:jobImage:remove')")
    @Log(title = "就业服务图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jobImageService.deleteJobImageByIds(ids));
    }
}
